package com.chenxi.controller;

import com.chenxi.model.User;
import com.chenxi.service.UserServiceI;
import com.chenxi.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping(value = "/userApi/")
public class UserController extends BaseController {
    @Autowired
    private UserServiceI userService;

    @RequestMapping(value = "page",method = RequestMethod.POST)
    public PageData<User> getPage(HttpServletRequest request){
        Map<String,String[]> params = request.getParameterMap();
        int draw = Integer.parseInt(request.getParameter("draw"));

        PageData<User> pageData = new PageData();
        pageData.setData(userService.find(null));
        pageData.setDraw(draw);
        pageData.setRecordsFiltered(1);
        pageData.setRecordsTotal(1);
        return pageData;
    }

    @RequestMapping(value = "test")
    public String getStr(){
        return "getStr";
    }

}

